package com.sebarmeli.applogic0;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;

import com.sebarmeli.util.Browser;
import com.sebarmeli.util.PropertyLoader;
import com.sebarmeli.webdriver.WebDriverFactory;
import com.sebarmeli.applogic0.LoginHelper0;
import com.sebarmeli.applogic.*;

public class ApplicationManager0 implements ApplicationManager {
	private String baseUrl;
	private String gridHubUrl;
	private Browser browser;
	private WebDriver driver;
	private LoginHelper0 LoginHelper;
	private NavigationHelper0 NavigationHelper;
	private FilmHelper0 FilmHelper;
	public ApplicationManager0()
	{
		
		baseUrl = PropertyLoader.loadProperty("site.url");
		gridHubUrl = PropertyLoader.loadProperty("grid2.hub");

		browser = new Browser();
		browser.setName(PropertyLoader.loadProperty("browser.name"));
		browser.setVersion(PropertyLoader.loadProperty("browser.version"));
		browser.setPlatform(PropertyLoader.loadProperty("browser.platform"));

		String username = PropertyLoader.loadProperty("user.username");
		String password = PropertyLoader.loadProperty("user.password");
		
		driver = WebDriverFactory.getInstance(gridHubUrl, browser, username,
				password);
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		LoginHelper=new LoginHelper0(this);
		NavigationHelper=new NavigationHelper0(this);
		FilmHelper=new FilmHelper0(this);
		
	}
	
     public void stop() 
     {
	     if (driver != null) 
		 driver.quit();
     }
     
     public LoginHelper0 getLoginHelper() 
     {return LoginHelper;}
     
     public FilmHelper0 getFilmHelper()
     {return FilmHelper;}
 
     public NavigationHelper0 getNavigationHelper()
     {return NavigationHelper;}
    	 
    	

     public WebDriver getWebDriver() {
       return driver;
     }

     public  String getBaseUrl() {
       return baseUrl;
     }

}
